bool Remove( T value )

robot_2Generated
code_blocksInput

Description

The Remove method is used to remove the first occurrence of a specific object from the NetList<T>. This method is part of the Sandbox.NetList<T> class, which is a networkable list designed to efficiently synchronize changes across the network.

Usage

To use the Remove method, call it on an instance of NetList<T> with the item you wish to remove as the parameter. The method returns a bool indicating whether the item was successfully removed.

Parameters:

  • value (T): The item to remove from the list.

Returns: bool - true if the item was successfully removed; otherwise, false.

Example

// Example of using the Remove method
public class MyComponent : Component
{
    [Sync] public NetList<int> MyIntegerList { get; set; } = new();

    public void RemoveNumber(int number)
    {
        if (IsProxy) return;
        bool removed = MyIntegerList.Remove(number);
        if (removed)
        {
            // Item was successfully removed
        }
        else
        {
            // Item was not found in the list
        }
    }
}